/**
 * Copyright 2019-2020 Huawei Technologies Co., Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <gtest/gtest.h>


#include "graph/node.h"
#include "graph/op_desc.h"
#include <string>
#define protected public
#define private public
#include "common/configuration.h"
#include "graph/utils/attr_utils.h"
#include "graph/utils/graph_utils.h"
#include "graph/utils/op_desc_utils.h"
#include "graph/utils/tensor_utils.h"
#include "common/util/op_info_util.h"
#include "ops_store/op_kernel_info.h"
#include "common/op_info_common.h"
#include "adapter/tbe_adapter/tbe_info/tbe_single_op_info_assembler.h"
#undef protected
#undef private

using namespace std;
using namespace ge;
using namespace fe;
using namespace te;

class UTEST_TbeSingleOpInfoAssembler : public testing::Test
{
};

TEST_F(UTEST_TbeSingleOpInfoAssembler, Test_Feed_Flag_Int64_To_Tbe_Op_Info){
  std::string op_name    = "conv";
  std::string op_module   = "";
  std::string op_type     = "tbe";
  std::string core_type   = "AIcoreEngine";

  vector<int64_t> dim_data = {1024, 3, 1024, 1024};
  GeShape shape_data(dim_data);
  GeTensorDesc data_desc(shape_data, FORMAT_NCHW, DT_FLOAT);
  vector<int64_t> dim_weight = {1024, 3, 1024, 1024};
  GeShape shape_weight(dim_weight);
  GeTensorDesc weight_desc(shape_weight);

  vector<int64_t> dim_out = {1024, 3, 1024, 3};
  GeShape shape_out(dim_out);
  GeTensorDesc OutDesc(shape_out);

  OpDescPtr conv_op = std::make_shared<OpDesc>("Conv", "conv");
  conv_op->AddInputDesc("x", data_desc);
  conv_op->AddInputDesc("w1", weight_desc);
  conv_op->AddOutputDesc("y", OutDesc);

  ComputeGraphPtr graph = std::make_shared<ComputeGraph>("test");
  NodePtr node_ptr = graph->AddNode(conv_op);
  Node* node = node_ptr.get();

  TbeSingleOpInfoAssembler Feed_Flag_Int64_To_Tbe_Op_Info;
  TbeOpInfo op_info(op_name, op_module, op_type, "", core_type);
  Status ret = Feed_Flag_Int64_To_Tbe_Op_Info.FeedFlagInt64ToTbeOpInfo(node, op_info);
  EXPECT_EQ(fe::SUCCESS, ret);
}